package com.vone.view;

import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.vone.dao.GetCompany;
import com.vone.export.Export;
import com.vone.ui.MyCheckBox;
import com.vone.ui.MyComboBox;
import com.vone.ui.MyPageJLabel;
import com.vone.until.db.MyJdbcConfig;
import com.vone.util.RegularExpressionUtil;
import com.vone.util.SizeCalculationUtil;
/**
 * 标题下部分主面板
 * @author wd
 *
 */
public class MainJPanelView extends JPanel {
	private static final long serialVersionUID = 1L;
	//搜索面板
	private SearchJPanel searchJPanel = null;
	//表格面板
	private JPanel tableJPanel = null;
	//表格表头
	private TableHeaderJPanel tableHeaderJPanel = null;
	//表格行集合面板
	private JPanel tableRowListJPanel = null;
	//表格-行
	private TableRowJPanel tableRowJPanel = null;
	//分页面板、操作
	private OperationJPanel operationJPanel = null;
	
	//所搜索导出的总条数
	private int derivedNumber = 0;
	//计算工具
	private SizeCalculationUtil sizeUtil = new SizeCalculationUtil();
	//14号字体大小
	private  Font font_14 = new Font("微软雅黑", Font.PLAIN, sizeUtil.getFontSize(14));
	//界面主黑色字体
	private static Color blackFontColor = new Color(88,88,88);
	//界面主黑色字体
	private static Color whiteFontColor = new Color(255,255,255);
	//面板边框颜色
	private Color jpanelBorderColor = new Color(224,224,224);
	//文本框边框颜色
	private Color textBorderColor = new Color(39,157,227);
	List<Map<String, String>> list=null;
	Map<String,String> mm=null;//搜索用来存放的数据
	public MainJPanelView(){
		this.setLayout(null);
		this.setBackground(new Color(240,240,240));
		
		//搜索面板
		searchJPanel = new SearchJPanel();
		//表格面板
		tableJPanel = new JPanel();
		tableJPanel.setLayout(null);
		tableJPanel.setBackground(Color.white);
		tableJPanel.setBorder(BorderFactory.createLineBorder(jpanelBorderColor));
		//表头
		tableHeaderJPanel = new TableHeaderJPanel();
		tableJPanel.add(tableHeaderJPanel);
		//表格行集合面板
		tableRowListJPanel = new JPanel();
		tableRowListJPanel.setLayout(null);
		tableRowListJPanel.setBackground(Color.white);
		
		//分页面板
		operationJPanel = new OperationJPanel();
		
		//各大板块布局
		searchJPanel.setBounds(sizeUtil.getX(10), sizeUtil.getY(10), sizeUtil.getW(880), sizeUtil.getH(40));//搜索面板
		tableJPanel.setBounds(sizeUtil.getX(10), sizeUtil.getY(60), sizeUtil.getW(880), sizeUtil.getH(402));//表格面板
		operationJPanel.setBounds(sizeUtil.getX(10), sizeUtil.getY(472), sizeUtil.getW(880), sizeUtil.getH(120));//分页面板
		this.add(searchJPanel);
		this.add(tableJPanel);
		this.add(operationJPanel);
		//查询封装显示数据
		MyJdbcConfig.init();//读取数据库配置文件
		executeQuery();
	}
	public int getDerivedNumber() {
		return derivedNumber;
	}
	public void setDerivedNumber(int derivedNumber) {
		this.derivedNumber = derivedNumber;
	}
	public OperationJPanel getOperationJPanel() {
		return operationJPanel;
	}
	public SearchJPanel getSearchJPanel() {
		return searchJPanel;
	}
	public JPanel getTableRowListJPanel() {
		return tableRowListJPanel;
	}
	//画出下边框
	public void paint(Graphics g) {
		super.paint(g);
		g.setColor(new Color(225,226,227));
		g.drawLine(0, getHeight()-1, getWidth() - 1, getHeight() - 1);
	}
	
	/**
	 * 把数据封装显示到表格
	 * @param list
	 */
	public void integralTabSettingData(List<Map<String, String>> list){
		tableRowListJPanel.removeAll();
		tableRowListJPanel.repaint();
		
		if(list!=null){
			int tabforHigh = 36;//每行占的高
			int listSize = list.size();
			for (int i = 0; i < listSize; i++) {
				if(i==0){tabforHigh=0;}
				Map<String, Object> m = new HashMap<String, Object>();
				m.put("id", list.get(i).get("id"));
				m.put("serialNumber", (1 + i) + (getOperationJPanel().getCurrentPage() * 10 - 10));
				m.put("name", list.get(i).get("username")==null?"":list.get(i).get("username"));
				m.put("credentialNo", list.get(i).get("company_name")==null?"":list.get(i).get("company_name"));
				m.put("baggageCode", list.get(i).get("person_name")==null?"":list.get(i).get("person_name"));
				m.put("cabinCode",list.get(i).get("mobile")==null?"":list.get(i).get("mobile"));
				m.put("deck", list.get(i).get("landline")==null?"":list.get(i).get("landline"));
				m.put("status", Integer.parseInt(list.get(i).get("status"))==1?"已提交":"未提交");
				tableRowJPanel = new TableRowJPanel(m,tabforHigh);
				tableRowListJPanel.add(tableRowJPanel);
				tabforHigh += 36;
			}
			tableRowListJPanel.setBounds(sizeUtil.getX(1), sizeUtil.getY(41), sizeUtil.getW(878), sizeUtil.getH(360));
			tableJPanel.add(tableRowListJPanel);
		}
	}
	
	/**
	 * 执行分页查询
	 */
	public void executeQuery(){
		final String  enterpriseNameValue = getSearchJPanel().getEnterpriseNameValue().getText().trim();
		final String  parameterGroupValue = getSearchJPanel().getParameterGroupValue().getSelectedItem().toString();
		final String  submitTypeValue = getSearchJPanel().getSubmitTypeValue().getSelectedItem().toString();
		
		Map<String, String> queryMap = new HashMap<String, String>();
		queryMap.put("company_name", enterpriseNameValue);
		if("不限".equals(parameterGroupValue)){
			queryMap.put("user_group_type", "-1");
		}else if("初创组".equals(parameterGroupValue)){
			queryMap.put("user_group_type", "1");
		}else if("成长组".equals(parameterGroupValue)){
			queryMap.put("user_group_type", "2");
		}
		if("不限".equals(submitTypeValue)){
			queryMap.put("submit", "-1");
		}else if("已提交".equals(submitTypeValue)){
			queryMap.put("submit", "1");
		}else if("未提交".equals(submitTypeValue)){
			queryMap.put("submit", "0");
		}
		
		int allSum = GetCompany.getListfinanceTypeSum(queryMap);
		int currentPage = getOperationJPanel().getCurrentPage();
		//设置总页数
		getOperationJPanel().setAllPage(allSum % 10 == 0 ? allSum / 10 : allSum / 10 + 1);
		//设置显示总信息
		getOperationJPanel().getRecordValue().setText("共 " + getOperationJPanel().getAllPage() + " 页 " + allSum + " 条");
		
		//查询设置数据
		integralTabSettingData(GetCompany.getListfinanceType(queryMap,currentPage));
	}
	
	/**
	 * 执行查询所搜索的全部企业信息
	 */
	public List<Map<String, String>> executeQueryExportAll(){
		final String  enterpriseNameValue = getSearchJPanel().getEnterpriseNameValue().getText().trim();
		final String  parameterGroupValue = getSearchJPanel().getParameterGroupValue().getSelectedItem().toString();
		final String  submitTypeValue = getSearchJPanel().getSubmitTypeValue().getSelectedItem().toString();
		
		Map<String, String> queryMap = new HashMap<String, String>();
		queryMap.put("company_name", enterpriseNameValue);
		if("不限".equals(parameterGroupValue)){
			queryMap.put("user_group_type", "-1");
		}else if("初创组".equals(parameterGroupValue)){
			queryMap.put("user_group_type", "1");
		}else if("成长组".equals(parameterGroupValue)){
			queryMap.put("user_group_type", "2");
		}
		if("不限".equals(submitTypeValue)){
			queryMap.put("submit", "-1");
		}else if("已提交".equals(submitTypeValue)){
			queryMap.put("submit", "1");
		}else if("未提交".equals(submitTypeValue)){
			queryMap.put("submit", "0");
		}
		//总条数
		setDerivedNumber(GetCompany.getListfinanceTypeSum(queryMap));
		//查询设置数据
		return GetCompany.getExecuteQueryExportAll(queryMap);
	}
	
	/**
	 * 搜索面板
	 * @author wd
	 *
	 */
	class SearchJPanel extends JPanel{
		private static final long serialVersionUID = 1L;
		
		private JLabel enterpriseName = null;//企业名称
		private JTextField enterpriseNameValue = null;//企业名称值
		private JLabel parameterGroup = null;//参赛组类型
		private MyComboBox parameterGroupValue = null;//参赛组类型值
		private JLabel submitType = null;//提交类型
		private MyComboBox submitTypeValue = null;//提交类型值
		private JLabel queryBtn = null;//查询按钮
		
		@SuppressWarnings("unchecked")
		public SearchJPanel(){
			this.setLayout(null);
			this.setBackground(Color.white);
			this.setBorder(BorderFactory.createLineBorder(jpanelBorderColor));
			
			enterpriseName = new JLabel("企业名称：");
			enterpriseNameValue = new JTextField();
			parameterGroup = new JLabel("参赛组类型：");
			parameterGroupValue = new MyComboBox();
			submitType = new JLabel("提交类型：");
			submitTypeValue = new MyComboBox();
			queryBtn = new JLabel("查 询",JLabel.CENTER);
			
			//设置文本框边框及颜色
			enterpriseNameValue.setBorder(BorderFactory.createLineBorder(textBorderColor));
			//设置按钮背景颜色及边框
			queryBtn.setOpaque(true);//设置组件JLabel不透明，只有设置为不透明，设置背景色才有效  
			queryBtn.setBackground(textBorderColor);
			queryBtn.setBorder(BorderFactory.createLineBorder(textBorderColor));
			//设置字体样式与字体颜色
			enterpriseName.setFont(font_14);
			enterpriseNameValue.setFont(font_14);
			parameterGroup.setFont(font_14);
			parameterGroupValue.setFont(font_14);
			submitType.setFont(font_14);
			submitTypeValue.setFont(font_14);
			queryBtn.setFont(font_14);
			//设置字体颜色
			enterpriseName.setForeground(blackFontColor);
			enterpriseNameValue.setForeground(blackFontColor);
			parameterGroup.setForeground(blackFontColor);
			parameterGroupValue.setForeground(blackFontColor);
			submitType.setForeground(blackFontColor);
			submitTypeValue.setForeground(blackFontColor);
			queryBtn.setForeground(whiteFontColor);
			
			
			//parameterGroupValue.addItem("不限");
			parameterGroupValue.addItem("初创组");
			parameterGroupValue.addItem("成长组");
			
			//submitTypeValue.addItem("不限");
			submitTypeValue.addItem("已提交");
			submitTypeValue.addItem("未提交");
			
			//位置布局
			enterpriseName.setBounds(sizeUtil.getX(10), sizeUtil.getY(7), sizeUtil.getW(80), sizeUtil.getH(26));
			enterpriseNameValue.setBounds(sizeUtil.getX(90), sizeUtil.getY(7), sizeUtil.getW(190), sizeUtil.getH(26));
			parameterGroup.setBounds(sizeUtil.getX(300), sizeUtil.getY(7), sizeUtil.getW(90), sizeUtil.getH(26));
			parameterGroupValue.setBounds(sizeUtil.getX(390), sizeUtil.getY(7), sizeUtil.getW(130), sizeUtil.getH(26));
			submitType.setBounds(sizeUtil.getX(540), sizeUtil.getY(7), sizeUtil.getW(80), sizeUtil.getH(26));
			submitTypeValue.setBounds(sizeUtil.getX(620), sizeUtil.getY(7), sizeUtil.getW(130), sizeUtil.getH(26));
			queryBtn.setBounds(sizeUtil.getX(770), sizeUtil.getY(7), sizeUtil.getW(70), sizeUtil.getH(26));
			
			this.add(enterpriseName);
			this.add(enterpriseNameValue);
			this.add(parameterGroup);
			this.add(parameterGroupValue);
			this.add(submitType);
			this.add(submitTypeValue);
			this.add(queryBtn);
			
			//查询(绑定事件)
			queryBtn.addMouseListener(new MouseAdapter(){
				//点击事件
				public void mousePressed(MouseEvent e){
					getOperationJPanel().getMyCoverJPanel(new Runnable() {
						@Override
						public void run() {
							//设置当前页为1
							getOperationJPanel().setCurrentPage(1);
							//修改显示的页码
							getOperationJPanel().updatePageNumberJTF(1);
							//查询封装显示数据
							executeQuery();
						}
					});
			    }
				//鼠标进入事件
				public void mouseEntered(MouseEvent e) {
					queryBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标变成手型
				}
				//鼠标移出事件
				public void mouseExited(MouseEvent e) {
					queryBtn.setCursor(Cursor.getDefaultCursor());//鼠标变回默认
				}
			});
		}

		public JTextField getEnterpriseNameValue() {
			return enterpriseNameValue;
		}
		public MyComboBox getParameterGroupValue() {
			return parameterGroupValue;
		}
		public MyComboBox getSubmitTypeValue() {
			return submitTypeValue;
		}
	}
	
	/**
	 * 表格表头
	 * @author wd
	 *
	 */
	class TableHeaderJPanel extends JPanel{
		private static final long serialVersionUID = 1L;
		private MyCheckBox checkBox = null;//复选框
		private JLabel serialNumber = null;//序号
		private JLabel name = null;//用户名
		private JLabel credentialNo = null;//公司名
		private JLabel baggageCode = null;//法人
		private JLabel cabinCode = null;//移动电话
		private JLabel deck = null;//固定电话
		private JLabel status = null;//状态
		
		public TableHeaderJPanel(){
			this.setLayout(null);
			this.setBackground(textBorderColor);
			
			checkBox = new MyCheckBox();
			serialNumber = new JLabel("序号",JLabel.CENTER);
			name = new JLabel("用户名",JLabel.CENTER);
			credentialNo = new JLabel("公司名称",JLabel.CENTER);
			baggageCode = new JLabel("法人",JLabel.CENTER);
			cabinCode = new JLabel("手机号码",JLabel.CENTER);
			deck = new JLabel("座机号码",JLabel.CENTER);
			status = new JLabel("状态",JLabel.CENTER);
			
			//设置字体样式与字体颜色
			serialNumber.setFont(font_14);
			name.setFont(font_14);
			credentialNo.setFont(font_14);
			baggageCode.setFont(font_14);
			cabinCode.setFont(font_14);
			deck.setFont(font_14);
			status.setFont(font_14);
			//设置字体颜色
			serialNumber.setForeground(whiteFontColor);
			name.setForeground(whiteFontColor);
			credentialNo.setForeground(whiteFontColor);
			baggageCode.setForeground(whiteFontColor);
			cabinCode.setForeground(whiteFontColor);
			deck.setForeground(whiteFontColor);
			status.setForeground(whiteFontColor);
			
			//位置布局
			checkBox.setBounds(sizeUtil.getX(0), sizeUtil.getY(0), sizeUtil.getW(40), sizeUtil.getH(39));
			serialNumber.setBounds(sizeUtil.getX(40), sizeUtil.getY(0), sizeUtil.getW(50), sizeUtil.getH(39));
			name.setBounds(sizeUtil.getX(90), sizeUtil.getY(0), sizeUtil.getW(100), sizeUtil.getH(39));
			credentialNo.setBounds(sizeUtil.getX(190), sizeUtil.getY(0), sizeUtil.getW(300), sizeUtil.getH(39));
			baggageCode.setBounds(sizeUtil.getX(490), sizeUtil.getY(0), sizeUtil.getW(90), sizeUtil.getH(39));
			cabinCode.setBounds(sizeUtil.getX(580), sizeUtil.getY(0), sizeUtil.getW(120), sizeUtil.getH(39));
			deck.setBounds(sizeUtil.getX(700), sizeUtil.getY(0), sizeUtil.getW(120), sizeUtil.getH(39));
			status.setBounds(sizeUtil.getX(820), sizeUtil.getY(0), sizeUtil.getW(58), sizeUtil.getH(39));
			//添加显示
			this.add(checkBox);
			this.add(serialNumber);
			this.add(name);
			this.add(credentialNo);
			this.add(baggageCode);
			this.add(cabinCode);
			this.add(deck);
			this.add(status);
			this.setBounds(sizeUtil.getX(1), sizeUtil.getY(1), sizeUtil.getW(878), sizeUtil.getH(39));
			//全选点击事件
			checkBox.addActionListener(new ActionListener() {
	            public void actionPerformed(ActionEvent arg0) {
	            	Component[] coms = getTableRowListJPanel().getComponents();//获得所有组件
	            	for(Component com:coms){
	            		if(com instanceof TableRowJPanel){
	            			//实现全选
	            			((TableRowJPanel)com).getCheckBox().setSelected(checkBox.isSelected());
	            		}
	            	}
	            }
	        });
		}
		public MyCheckBox getCheckBox() {
			return checkBox;
		}
		public void setCheckBox(MyCheckBox checkBox) {
			this.checkBox = checkBox;
		}
	}
	
	/**
	 * 表格每一行
	 * @author wd
	 *
	 */
	class TableRowJPanel extends JPanel{
		private static final long serialVersionUID = 1L;
		private MyCheckBox checkBox = null;//复选框
		private JLabel serialNumber = null;//序号
		private JLabel name = null;//用户名
		private JLabel credentialNo = null;//公司名
		private JLabel baggageCode = null;//法人
		private JLabel cabinCode = null;//移动电话
		private JLabel deck = null;//固定电话
		private JLabel status = null;//状态
		
		public TableRowJPanel(Map<String, Object> map,int tabforHigh){
			this.setLayout(null);
			this.setBackground(Color.white);
			
			checkBox = new MyCheckBox();
			checkBox.setId(map.get("id").toString());
			serialNumber = new JLabel(map.get("serialNumber").toString(),JLabel.CENTER);
			name = new JLabel(map.get("name").toString(),JLabel.CENTER);
			credentialNo = new JLabel(map.get("credentialNo").toString(),JLabel.CENTER);
			baggageCode = new JLabel(map.get("baggageCode").toString(),JLabel.CENTER);
			cabinCode = new JLabel(map.get("cabinCode").toString(),JLabel.CENTER);
			deck = new JLabel(map.get("deck").toString(),JLabel.CENTER);
			status = new JLabel(map.get("status").toString(),JLabel.CENTER);
			
			//设置字体样式与字体颜色
			serialNumber.setFont(font_14);
			name.setFont(font_14);
			credentialNo.setFont(font_14);
			baggageCode.setFont(font_14);
			cabinCode.setFont(font_14);
			deck.setFont(font_14);
			status.setFont(font_14);
			//设置字体颜色
			serialNumber.setForeground(blackFontColor);
			name.setForeground(blackFontColor);
			credentialNo.setForeground(blackFontColor);
			baggageCode.setForeground(blackFontColor);
			cabinCode.setForeground(blackFontColor);
			deck.setForeground(blackFontColor);
			status.setForeground(blackFontColor);
			
			//位置布局
			checkBox.setBounds(sizeUtil.getX(0), sizeUtil.getY(0), sizeUtil.getW(40), sizeUtil.getH(39));
			serialNumber.setBounds(sizeUtil.getX(40), sizeUtil.getY(0), sizeUtil.getW(50), sizeUtil.getH(39));
			name.setBounds(sizeUtil.getX(90), sizeUtil.getY(0), sizeUtil.getW(100), sizeUtil.getH(39));
			credentialNo.setBounds(sizeUtil.getX(190), sizeUtil.getY(0), sizeUtil.getW(300), sizeUtil.getH(39));
			baggageCode.setBounds(sizeUtil.getX(490), sizeUtil.getY(0), sizeUtil.getW(90), sizeUtil.getH(39));
			cabinCode.setBounds(sizeUtil.getX(580), sizeUtil.getY(0), sizeUtil.getW(120), sizeUtil.getH(39));
			deck.setBounds(sizeUtil.getX(700), sizeUtil.getY(0), sizeUtil.getW(120), sizeUtil.getH(39));
			status.setBounds(sizeUtil.getX(820), sizeUtil.getY(0), sizeUtil.getW(58), sizeUtil.getH(39));
			//添加显示
			this.add(checkBox);
			this.add(serialNumber);
			this.add(name);
			this.add(credentialNo);
			this.add(baggageCode);
			this.add(cabinCode);
			this.add(deck);
			this.add(status);
			this.setBounds(sizeUtil.getX(0), sizeUtil.getY(tabforHigh), sizeUtil.getW(878), sizeUtil.getH(36));
			/*
			//点击事件
			checkBox.addActionListener(new ActionListener() {
	            public void actionPerformed(ActionEvent arg0) {
	            	System.out.println("当前复选框的值为："+getCheckBox().getId());
	            	//执行任务.................
	            }
	        });
			*/
		}
		public String getUserName() {
			return name.getText().toString();
		}
		//画出下边框
		public void paint(Graphics g) {
			super.paint(g);
			g.setColor(new Color(39,157,227));
			g.drawLine(0, getHeight()-1, getWidth() - 1, getHeight() - 1);
		}
		public MyCheckBox getCheckBox() {
			return checkBox;
		}
		public void setCheckBox(MyCheckBox checkBox) {
			this.checkBox = checkBox;
		}
	}
	
	/**
	 * 操作面板
	 * @author wd
	 *
	 */
	class OperationJPanel extends JPanel{
		private static final long serialVersionUID = 1L;
		
		private JLabel record = null;//记录
		private JLabel recordValue = null;//记录值
		private MyPageJLabel homePageBtn = null;//首页
		private MyPageJLabel previousPageBtn = null;//上一页
		private JLabel displayCurrentPage = null;//当前页
		private MyPageJLabel nextPageBtn = null;//下一页
		private MyPageJLabel shadowePageBtn = null;//尾页
		//跳转面板
		private JPanel jumpJPanel = null;
		private JTextField howManyPages = null;//多少页
		private JLabel page = null;//页
		private JLabel goToBtn = null;//转到按钮
		
		private int allSum = 0;// 总条数
		private int allPage = 0;// 总页数
		private int currentPage = 1;// 当前页数
		
		//导出按钮
		private JLabel exportBtn = null;
		//导出所搜索的企业
		private JLabel exportAllBtn = null;
		
		public OperationJPanel(){
			this.setLayout(null);
			this.setBackground(new Color(240,240,240));
			
			record = new JLabel("记录：");
			recordValue = new JLabel("共0页0条");
			
			homePageBtn = new MyPageJLabel("首页",JLabel.CENTER);
			previousPageBtn = new MyPageJLabel("<<",JLabel.CENTER);
			displayCurrentPage = new JLabel("1",JLabel.CENTER);
			nextPageBtn = new MyPageJLabel(">>",JLabel.CENTER);
			shadowePageBtn = new MyPageJLabel("尾页",JLabel.CENTER);
			//分页板块
			jumpJPanel = new JPanel();
			jumpJPanel.setLayout(null);
			howManyPages = new JTextField("");
			page = new JLabel("页",JLabel.CENTER);
			goToBtn = new JLabel("转 到",JLabel.CENTER);
			
			//导出按钮
			exportBtn = new JLabel("导出选中的企业",JLabel.CENTER);
			exportAllBtn = new JLabel("导出查询的全部",JLabel.CENTER);
			
			//设置文本框边框及颜色
			howManyPages.setBorder(BorderFactory.createLineBorder(Color.white));
			//设置按钮背景颜色及边框
			displayCurrentPage.setOpaque(true);//设置组件JLabel不透明，只有设置为不透明，设置背景色才有效  
			displayCurrentPage.setBackground(textBorderColor);
			displayCurrentPage.setBorder(BorderFactory.createLineBorder(textBorderColor));
			goToBtn.setOpaque(true);//设置组件JLabel不透明，只有设置为不透明，设置背景色才有效  
			goToBtn.setBackground(textBorderColor);
			goToBtn.setBorder(BorderFactory.createLineBorder(textBorderColor));
			exportBtn.setOpaque(true);//设置组件JLabel不透明，只有设置为不透明，设置背景色才有效  
			exportBtn.setBackground(textBorderColor);
			exportBtn.setBorder(BorderFactory.createLineBorder(textBorderColor));
			exportAllBtn.setOpaque(true);//设置组件JLabel不透明，只有设置为不透明，设置背景色才有效  
			exportAllBtn.setBackground(textBorderColor);
			exportAllBtn.setBorder(BorderFactory.createLineBorder(textBorderColor));
			//设置字体样式与字体颜色
			record.setFont(font_14);
			recordValue.setFont(font_14);
			homePageBtn.setFont(font_14);
			previousPageBtn.setFont(font_14);
			displayCurrentPage.setFont(font_14);
			nextPageBtn.setFont(font_14);
			shadowePageBtn.setFont(font_14);
			howManyPages.setFont(font_14);
			page.setFont(font_14);
			goToBtn.setFont(font_14);
			exportBtn.setFont(new Font("微软雅黑", Font.PLAIN, sizeUtil.getFontSize(20)));
			exportAllBtn.setFont(new Font("微软雅黑", Font.PLAIN, sizeUtil.getFontSize(20)));
			//设置字体颜色
			record.setForeground(blackFontColor);
			recordValue.setForeground(blackFontColor);
			homePageBtn.setForeground(blackFontColor);
			previousPageBtn.setForeground(blackFontColor);
			displayCurrentPage.setForeground(whiteFontColor);
			nextPageBtn.setForeground(blackFontColor);
			shadowePageBtn.setForeground(blackFontColor);
			howManyPages.setForeground(blackFontColor);
			page.setForeground(blackFontColor);
			goToBtn.setForeground(whiteFontColor);
			exportBtn.setForeground(whiteFontColor);
			exportAllBtn.setForeground(whiteFontColor);
			//设置分页按钮边框颜色
			homePageBtn.setBorder(BorderFactory.createLineBorder(jpanelBorderColor));
			previousPageBtn.setBorder(BorderFactory.createLineBorder(jpanelBorderColor));
			nextPageBtn.setBorder(BorderFactory.createLineBorder(jpanelBorderColor));
			shadowePageBtn.setBorder(BorderFactory.createLineBorder(jpanelBorderColor));
			jumpJPanel.setBorder(BorderFactory.createLineBorder(textBorderColor));
			//设置分页按钮背景颜色
			homePageBtn.setOpaque(true);//设置组件JLabel不透明，只有设置为不透明，设置背景色才有效  
			previousPageBtn.setOpaque(true);//设置组件JLabel不透明，只有设置为不透明，设置背景色才有效 
			nextPageBtn.setOpaque(true);//设置组件JLabel不透明，只有设置为不透明，设置背景色才有效  
			shadowePageBtn.setOpaque(true);//设置组件JLabel不透明，只有设置为不透明，设置背景色才有效  
			homePageBtn.setBackground(whiteFontColor);
			previousPageBtn.setBackground(whiteFontColor);
			nextPageBtn.setBackground(whiteFontColor);
			shadowePageBtn.setBackground(whiteFontColor);
			jumpJPanel.setBackground(whiteFontColor);
			
			record.setBounds(sizeUtil.getX(10), sizeUtil.getY(0), sizeUtil.getW(50), sizeUtil.getH(26));
			recordValue.setBounds(sizeUtil.getX(60), sizeUtil.getY(0), sizeUtil.getW(810), sizeUtil.getH(26));
			
			homePageBtn.setBounds(sizeUtil.getX(290), sizeUtil.getY(36), sizeUtil.getW(55), sizeUtil.getH(26));
			previousPageBtn.setBounds(sizeUtil.getX(345), sizeUtil.getY(36), sizeUtil.getW(35), sizeUtil.getH(26));
			displayCurrentPage.setBounds(sizeUtil.getX(380), sizeUtil.getY(36), sizeUtil.getW(60), sizeUtil.getH(26));
			nextPageBtn.setBounds(sizeUtil.getX(440), sizeUtil.getY(36), sizeUtil.getW(35), sizeUtil.getH(26));
			shadowePageBtn.setBounds(sizeUtil.getX(475), sizeUtil.getY(36), sizeUtil.getW(55), sizeUtil.getH(26));
			
			howManyPages.setBounds(sizeUtil.getX(1), sizeUtil.getY(1), sizeUtil.getW(50), sizeUtil.getH(24));
			page.setBounds(sizeUtil.getX(51), sizeUtil.getY(1), sizeUtil.getW(25), sizeUtil.getH(24));
			goToBtn.setBounds(sizeUtil.getX(76), sizeUtil.getY(1), sizeUtil.getW(64), sizeUtil.getH(24));
			jumpJPanel.add(howManyPages);
			jumpJPanel.add(page);
			jumpJPanel.add(goToBtn);
			jumpJPanel.setBounds(sizeUtil.getX(540), sizeUtil.getY(36), sizeUtil.getW(140), sizeUtil.getH(26));
			exportBtn.setBounds(sizeUtil.getX(225), sizeUtil.getY(80), sizeUtil.getW(200), sizeUtil.getH(40));
			exportAllBtn.setBounds(sizeUtil.getX(475), sizeUtil.getY(80), sizeUtil.getW(200), sizeUtil.getH(40));
			
			this.add(record);
			this.add(recordValue);
			this.add(homePageBtn);
			this.add(previousPageBtn);
			this.add(displayCurrentPage);
			this.add(nextPageBtn);
			this.add(shadowePageBtn);
			this.add(jumpJPanel);
			this.add(exportBtn);
			this.add(exportAllBtn);
			
			//导出事件
			exportBtn.addMouseListener(new MouseAdapter(){
				public void mousePressed(MouseEvent e){
					//定义选中的id集合
					final List<Map<String,String>> idList = new ArrayList<Map<String,String>>();
					Component[] coms = getTableRowListJPanel().getComponents();//获得所有组件
		        	for(Component com:coms){
		        		if(com instanceof TableRowJPanel){
		        			if(((TableRowJPanel)com).getCheckBox().isSelected()){
		        				Map<String,String> map = new HashMap<String, String>();
		        				map.put("id", ((TableRowJPanel)com).getCheckBox().getId());
		        				map.put("userName", ((TableRowJPanel)com).getUserName());
		        				map.put("groupType", getSearchJPanel().getParameterGroupValue().getSelectedItem().toString());
		        				map.put("submitType", getSearchJPanel().getSubmitTypeValue().getSelectedItem().toString());
		        				idList.add(map);
		        			}
		        		}
		        	}
					
					if(idList!=null && idList.size()>0){
						if(JOptionPane.showConfirmDialog(null, "你确定要导出所选择的 "+idList.size()+" 家企业信息吗？", "系统信息", JOptionPane.YES_NO_OPTION)==0){
							//实现进度状态
							getMyCoverJPanel(new Runnable() {
								@Override
								public void run() {
									Export export=new Export();
									export.exportbtnClickEvent(idList);
								}
							});
						}
					}else{
						JOptionPane.showMessageDialog(null, "请选择要导出的企业");
					}
				}
				//鼠标进入事件
				public void mouseEntered(MouseEvent e) {
					exportBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标变成手型
				}
				//鼠标移出事件
				public void mouseExited(MouseEvent e) {
					exportBtn.setCursor(Cursor.getDefaultCursor());//鼠标变回默认
				}
			});
			
			//导出全部按钮
			exportAllBtn.addMouseListener(new MouseAdapter(){
				public void mousePressed(MouseEvent e){
					getMyCoverJPanel(new Runnable() {
						@Override
						public void run() {
							List<Map<String,String>> allLiat = executeQueryExportAll();
							if(allLiat!=null && allLiat.size()>0){
								final List<Map<String,String>> idList = new ArrayList<Map<String,String>>();
								for (int i = 0; i < allLiat.size(); i++) {
									Map<String,String> map = new HashMap<String, String>();
			        				map.put("id", allLiat.get(i).get("id").toString());
			        				map.put("userName", allLiat.get(i).get("username").toString());
			        				map.put("groupType", getSearchJPanel().getParameterGroupValue().getSelectedItem().toString());
			        				map.put("submitType", getSearchJPanel().getSubmitTypeValue().getSelectedItem().toString());
			        				idList.add(map);
								}
								if(idList!=null && idList.size()>0){
									if(JOptionPane.showConfirmDialog(null, "你确定要导出所查询的 "+getDerivedNumber()+" 家企业信息吗？", "系统信息", JOptionPane.YES_NO_OPTION)==0){
										//导出
										conductAllExport(idList);
									}
								}
							}else{
								JOptionPane.showMessageDialog(null, "当前没有企业信息可以导出，请重新查询");
							}
						}
					});
				}
				//鼠标进入事件
				public void mouseEntered(MouseEvent e) {
					exportAllBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标变成手型
				}
				//鼠标移出事件
				public void mouseExited(MouseEvent e) {
					exportAllBtn.setCursor(Cursor.getDefaultCursor());//鼠标变回默认
				}
			});
			
			// 首页按钮事件
			homePageBtn.addMouseListener(new MouseAdapter() {
				@Override
				public void mousePressed(MouseEvent e) {
					getMyCoverJPanel(new Runnable() {
						@Override
						public void run() {
							if (ckeckSelected()) {
								JOptionPane.showMessageDialog(null, "导出只能选择当前页", "提示", JOptionPane.ERROR_MESSAGE);
								return;
							}
							currentPage = 1;
							updatePageNumberJTF(currentPage);
							//查询封装显示数据
							executeQuery();
						}
					});
				}
			});
			// 上一页按钮事件
			previousPageBtn.addMouseListener(new MouseAdapter() {
				@Override
				public void mousePressed(MouseEvent e) {
					getMyCoverJPanel(new Runnable() {
						@Override
						public void run() {
							if (ckeckSelected()) {
								JOptionPane.showMessageDialog(null,"导出只能选择当前页", "提示", JOptionPane.ERROR_MESSAGE);
								return;
							}
							if (currentPage > 1) {
								currentPage--;
							}
							updatePageNumberJTF(currentPage);
							//查询封装显示数据
							executeQuery();
						}
					});
				}
			});
			// 跳转按钮事件
			goToBtn.addMouseListener(new MouseAdapter() {
				@Override
				public void mousePressed(MouseEvent e) {
					getMyCoverJPanel(new Runnable() {
						@Override
						public void run() {
							if (ckeckSelected()) {
								JOptionPane.showMessageDialog(null,"导出只能选择当前页", "提示", JOptionPane.ERROR_MESSAGE);
								return;
							}
							if (howManyPages.getText().length() < 1 || !RegularExpressionUtil.checkNumber(howManyPages.getText().trim())) {
								JOptionPane.showMessageDialog(null, "请输入正确的数字", "提示", JOptionPane.ERROR_MESSAGE);
								return;
							}
							int strs = Integer.parseInt(howManyPages.getText().trim());
							if (strs < 1) {
								JOptionPane.showMessageDialog(null, "请输入正确的页码", "提示", JOptionPane.ERROR_MESSAGE);
								
								return;
							} else if (strs > allPage) {
								JOptionPane.showMessageDialog(null, "请输入正确的页码", "提示", JOptionPane.ERROR_MESSAGE);
								return;
							}
							currentPage = strs;
							updatePageNumberJTF(currentPage);
							//查询封装显示数据
							executeQuery();
						}
					});
				}
				//鼠标进入事件
				public void mouseEntered(MouseEvent e) {
					goToBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标变成手型
				}
				//鼠标移出事件
				public void mouseExited(MouseEvent e) {
					goToBtn.setCursor(Cursor.getDefaultCursor());//鼠标变回默认
				}
			});
			// 下一页按钮事件
			nextPageBtn.addMouseListener(new MouseAdapter() {
				@Override
				public void mousePressed(MouseEvent e) {
					getMyCoverJPanel(new Runnable() {
						@Override
						public void run() {
							if (ckeckSelected()) {
								JOptionPane.showMessageDialog(null, "导出只能选择当前页", "提示", JOptionPane.ERROR_MESSAGE);
								return;
							}
							if (currentPage < allPage) {
								currentPage++;
							}
							updatePageNumberJTF(currentPage);
							//查询封装显示数据
							executeQuery();
						}
					});
				}
			});
			// 尾页按钮事件
			shadowePageBtn.addMouseListener(new MouseAdapter() {
				@Override
				public void mousePressed(MouseEvent e) {
					getMyCoverJPanel(new Runnable() {
						@Override
						public void run() {
							if (ckeckSelected()) {
								JOptionPane.showMessageDialog(null, "导出只能选择当前页", "提示", JOptionPane.ERROR_MESSAGE);
								return;
							}
							if (allPage > 0) {
								currentPage = allPage;
							} else {
								currentPage = 1;
							}
							updatePageNumberJTF(currentPage);
							//查询封装显示数据
							executeQuery();
						}
					});
				}
			});
		}
		public void setAllSum(int allSum) {
			this.allSum = allSum;
		}
		public void setAllPage(int allPage) {
			this.allPage = allPage;
		}
		public void setCurrentPage(int currentPage) {
			this.currentPage = currentPage;
		}
		public JLabel getRecordValue() {
			return recordValue;
		}
		public int getAllSum() {
			return allSum;
		}
		public int getAllPage() {
			return allPage;
		}
		public int getCurrentPage() {
			return currentPage;
		}

		// 使用遮罩层方法
		private void getMyCoverJPanel(Runnable runnable) {
			new com.vone.ui.MyCoverJPanel(runnable, sizeUtil.getW(900), sizeUtil.getH(650), MianWindowJFrame.getMianWindowJFrame().getLayeredPane());
		}
		// 检查有没有选中-有就true
		private boolean ckeckSelected() {
			Component[] coms = getTableRowListJPanel().getComponents();//获得所有组件
        	for(Component com:coms){
        		if(com instanceof TableRowJPanel){
        			if(((TableRowJPanel)com).getCheckBox().isSelected()){
        				return true;
        			}
        		}
        	}
			return false;
		}
		// 修改页码文本框页码
		private void updatePageNumberJTF(int currentPage) {
			howManyPages.setText(String.valueOf(currentPage));
			displayCurrentPage.setText(String.valueOf(currentPage));
		}
		//进行导出所查询的全部
		private void conductAllExport(final List<Map<String,String>> idList){
			//实现进度状态
			getMyCoverJPanel(new Runnable() {
				@Override
				public void run() {
					Export export=new Export();
					export.exportbtnClickEvent(idList);
				}
			});
		}
	}
	
}
